package main

import (
	"EnjoyWorking/config"
	"EnjoyWorking/utils"
	"EnjoyWorking/utils/storage"
	"EnjoyWorking/web/middleware/auth"
	"EnjoyWorking/web/middleware/jwt"
	"EnjoyWorking/web/routers"
	jsoniter "github.com/json-iterator/go"
	"github.com/kataras/iris/v12"
	"github.com/liamylian/jsontime"
	"time"
)

func main()  {

	jsontime.SetDefaultTimeFormat("2006-01-02 15:04:05", time.Local)
	jsoniter.ConfigDefault.RegisterExtension(&jsontime.CustomTimeExtension{})

	app := iris.New()
	app.Logger().SetLevel("info")

	config := config.InitConfig()

	storage.InitRedis()
	storage.NewMysqlEngine()
	auth.InitAuth()
	jwt.InitJWT()
	utils.InitValidator()
	utils.InitLog()

	routers.Routers(app)

	addr := ":" + config.Port
	_ = app.Run(
		iris.Addr(addr),
		iris.WithoutServerError(iris.ErrServerClosed), //无服务错误提示
		iris.WithOptimizations,                        //对json数据序列化更快的配置)
	)
}
